package com.maimang.platform.shiro.realm;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @classname AuthenticationFilter
 * @description <br>自定义表单过滤器</br>
 * @author  Rocky
 * @date    2019-10-08 17:37
 * @email   jintaozhao@qq.com
 * @version 1.0.0
 */
public class AuthenticationFilter extends FormAuthenticationFilter {

	@Override
	protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) {
		String username = getUsername(request);
		String password = getPassword(request);
		boolean rememberMe = isRememberMe(request);

		boolean passwordLess = Boolean.parseBoolean(request.getParameter("passwordLess"));
		return new UserToken(username, password, rememberMe, passwordLess);
	}
}
